<template>
  <el-dialog
    title="用户登录"
    :visible="visible"
    width="500px"
    :before-close="beforeClose"
  >
    <el-form
      :model="form"
      :rules="rules"
      size="mini"
      label-width="100px"
      ref="form"
    >
      <el-form-item prop="chatType" label="chat模式：">
        <el-select v-model="form.chatType">
          <el-option label="一般问答" value="ANSWER_QA_MODE"></el-option>
          <el-option
            label="实事求是问答"
            value="ANSWER_FACTUAL_ANSWER_MODE"
          ></el-option>
          <el-option
            label="Javascript编程函数问答"
            value="ANSWER_FACTUAL_ANSWER_MODE"
          ></el-option>
          <el-option
            label="机器学习或人工智能模型向导问答"
            value="ANSWER_FACTUAL_ANSWER_MODE"
          ></el-option>
          <el-option
            label="一般分类器"
            value="CLASSIFY_NORMAL_MODE"
          ></el-option>
          <el-option
            label="高级推文分类器"
            value="CLASSIFY_ADVANCED_TWEET_MODE"
          ></el-option>
          <el-option
            label="文本内容关键字提取器"
            value="CLASSIFY_EXTRACT_KEYWORD_MODE"
          ></el-option>
          <el-option
            label="与朋友聊天"
            value="CONVERSATION_FRIDEND_CHAT_MODE"
          ></el-option>
          <el-option
            label="与AI助手开放式聊天"
            value="CONVERSATION_AI_OPEN_CHAT_MODE"
          ></el-option>
          <el-option
            label="与Marv聊天（具备事实性又带有讽刺色彩）"
            value="CONVERSATION_MARV_CHAT_MODE"
          ></el-option>
          <el-option
            label="英语翻译为其他语言"
            value="ENGLISH_TRANSLATION_MODE"
          ></el-option>
          <el-option
            label="为研究主题生成提纲"
            value="OUTLINE_ESSAY_MODE"
          ></el-option>
          <el-option label="代码开发模式向导" value="CODE_DEV_MODE"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="accountId" label="密码：">
        <el-input v-model="form.accountId" placeholder="请输入密码"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button size="mini" type="primary" @click="submit">登 录</el-button>
      <el-button size="mini" @click="closeDialog">取 消</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  name: "DialogOfAccount",
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    chatType: String,
    accountId: String,
  },
  components: {},
  watch: {
    visible: {
      handler(val) {
        if (val) {
          this.init();
        }
      },
      immediate: true,
    },
  },
  data() {
    return {
      form: {
        chatType: "CONVERSATION_AI_OPEN_CHAT_MODE",
        accountId: "",
      },
      rules: {
        accountId: [{ required: true, message: "请输入密码！" }],
      },
    };
  },
  methods: {
    init() {
      this.resetForm();
    },
    resetForm() {
      this.$refs.form && this.$refs.form.resetFields();
      if (this.chatType) this.form.chatType = this.chatType;
      if (this.accountId) this.form.accountId = this.accountId;
    },
    refreshData() {
      this.$emit("success", this.form);
    },
    beforeClose(done) {
      this.closeDialog();
      done();
    },
    closeDialog() {
      this.$emit("closeDialog", "dialogOfAccount");
    },
    submit() {
      this.refreshData();
      this.closeDialog();
    },
  },
};
</script>
<style lang="scss" scoped></style>
